package com.crealth.model;

import java.io.Serializable;
import java.sql.Timestamp;

import com.alibaba.fastjson.JSONObject;
import com.crealth.utils.Utils;

public class CreditReportModel implements Serializable {
	private static final long serialVersionUID = 722018535L;
	
	private long id;  // 征信报告
	private String searchDepartment;  // 查找部门
	private Timestamp searchDate;  // 查找日期
	private String khjl;  // 客户经理
	private String ajjl;  // 按揭经理
	private String consumerName;  // 客户姓名
	private String consumerPhone;  // 客户手机
	private String identity;  // 身份证号
	private String searchBank;  // 查询银行
	private Timestamp djBankTime;  // 递交银行时间
	private String djUser;  // 递交人
	private String djWay;  // 递交方式
	private String memo;  // 备注
	private String pictureFileName;  // 照片的文件名
	private String creditFileName;  // 征信报告的文件名
	
	public CreditReportModel() {
		id = 0;  // 征信报告
		searchDepartment = "";  // 查找部门
		searchDate = null;  // 查找日期
		khjl = "";  // 客户经理
		ajjl = "";  // 按揭经理
		consumerName = "";  // 客户姓名
		consumerPhone = "";  // 客户手机
		identity = "";  // 身份证号
		searchBank = "";  // 查询银行
		djBankTime = null;  // 递交银行时间
		djUser = "";  // 递交人
		djWay = "";  // 递交方式
		memo = "";  // 备注
		pictureFileName = "";  // 照片的文件名
		creditFileName = "";
	}
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public String getSearchDepartment() {
		return searchDepartment;
	}
	public void setSearchDepartment(String searchDepartment) {
		this.searchDepartment = searchDepartment;
	}
	public Timestamp getSearchDate() {
		return searchDate;
	}
	public void setSearchDate(Timestamp searchDate) {
		this.searchDate = searchDate;
	}
	public String getKhjl() {
		return khjl;
	}
	public void setKhjl(String khjl) {
		this.khjl = khjl;
	}
	public String getAjjl() {
		return ajjl;
	}
	public void setAjjl(String ajjl) {
		this.ajjl = ajjl;
	}
	public String getConsumerName() {
		return consumerName;
	}
	public void setConsumerName(String consumerName) {
		this.consumerName = consumerName;
	}
	public String getConsumerPhone() {
		return consumerPhone;
	}
	public void setConsumerPhone(String consumerPhone) {
		this.consumerPhone = consumerPhone;
	}
	public String getIdentity() {
		return identity;
	}
	public void setIdentity(String identity) {
		this.identity = identity;
	}
	public String getSearchBank() {
		return searchBank;
	}
	public void setSearchBank(String searchBank) {
		this.searchBank = searchBank;
	}
	public Timestamp getDjBankTime() {
		return djBankTime;
	}
	public void setDjBankTime(Timestamp djBankTime) {
		this.djBankTime = djBankTime;
	}
	public String getDjUser() {
		return djUser;
	}
	public void setDjUser(String djUser) {
		this.djUser = djUser;
	}
	public String getDjWay() {
		return djWay;
	}
	public void setDjWay(String djWay) {
		this.djWay = djWay;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	public String getPictureFileName() {
		return pictureFileName;
	}
	public void setPictureFileName(String pictureFileName) {
		this.pictureFileName = pictureFileName;
	}
	public String getCreditFileName() {
		return creditFileName;
	}
	public void setCreditFileName(String creditFileName) {
		this.creditFileName = creditFileName;
	}
	
	public void parseFromJson(JSONObject jsonData) {
		this.id = Utils.getJsonIntValue(jsonData, "creditRptID", 0);
		searchDepartment = Utils.getJsonString(jsonData, "department");  // 查找部门
		if (jsonData.containsKey("searchDate")) {
			long nt = jsonData.getLong("searchDate");
			searchDate = new Timestamp(nt * 1000);  // 查找日期
		}
		khjl = Utils.getJsonString(jsonData, "khjl");  // 客户经理
		ajjl = Utils.getJsonString(jsonData, "ajjl");  // 按揭经理
		consumerName = Utils.getJsonString(jsonData, "consumerName");  // 客户姓名
		consumerPhone = Utils.getJsonString(jsonData, "consumerPhone");  // 客户手机
		identity = Utils.getJsonString(jsonData, "identity");  // 身份证号
		searchBank = Utils.getJsonString(jsonData, "searchBank");  // 查询银行
		if (jsonData.containsKey("djBankTime")) {
			long djt = jsonData.getLongValue("djBankTime");
			djBankTime = new Timestamp(djt * 1000);  // 递交银行时间
		}
		djUser = Utils.getJsonString(jsonData, "djUser");  // 递交人
		djWay = Utils.getJsonString(jsonData, "djWay");  // 递交方式
		memo = Utils.getJsonString(jsonData, "memo");  // 备注
	}
	
	public JSONObject toJSONObject() {
		JSONObject resJson = new JSONObject();
		resJson.put("id", id);
		if (searchDate != null) {			
			resJson.put("searchDate", searchDate.getTime() / 1000);
		}
		if (searchDepartment != null && searchDepartment.length() > 0) {
			resJson.put("department", searchDepartment);
		}
		resJson.put("khjl", khjl);
		resJson.put("ajjl", ajjl);
		resJson.put("consumerName", consumerName);
		resJson.put("consumerPhone", consumerPhone);
		resJson.put("identity", identity);
		resJson.put("searchBank", searchBank);
		if (djBankTime != null) {
			resJson.put("djBankTime", djBankTime.getTime() / 1000);
		}
		resJson.put("djUser", djUser);
		resJson.put("djWay", djWay);
		resJson.put("memo", memo);
		if (pictureFileName != null && pictureFileName.length() > 0) {
			resJson.put("picFileName", pictureFileName);
		}
		if (creditFileName != null && creditFileName.length() > 0) {
			resJson.put("creditFileName", creditFileName);
		}
		
		return resJson;
	}
		
		
		
		

}
